const express = require( 'express' );
const cookieSession = require( 'cookie-session' );

const app = express();
app.listen( 8080 );

//中间件
app.use( cookieSession( {
    name: 'js',
    secret: 'fsjgahlraeiorghoiRH',
    maxAge: 20 * 60 * 1000
} ) );

app.get( '/login', ( req, res ) => {
    req.session[ 'username' ] = 'aabbcc';
    res.send( '设置成功' );
} );
app.get( '/index', ( req, res ) => {
    res.send( req.session[ 'username' ] );
} );